<?php
/*
Primary Developer: Derek Shue
Updated: 12/10/2011
Module Description: CourseAssociations
*/
class Application_Model_CourseAssociationQuery
{
    public function init(){
	}

	/**
	* Returns all course associations for the admin view.
	* Term and Termmodifier behave as defined in Application_Model_Term
	*/
	public function selectCAs_Admin($term, $termModifier, $name){
		$terms = new Application_Model_Term();
		try{
		   $term_list = $terms->getTerms($term, $termModifier);
		}
		catch(Exception $e){
			return Null;
		}
		$associationModel = new Application_Model_DbTable_CourseAssociations();
		$query = 'TERM in ' . $term_list;
		try{
				$rows = $associationModel->fetchAll($query)->toArray();
			}
		catch(Exception $e){
			$rows = Null;
		}
		return $rows;
    }
	
	/**
	* Returns all course associations for the specified course
	* Term and Termmodifier behave as defined in Application_Model_Term
	*/
	public function selectCAs_Course($CID){
		$associationModel = new Application_Model_DbTable_CourseAssociations();
		$query = 'CID = ' . $CID;
		try{
				$rows = $associationModel->fetchAll($query)->toArray();
			}
		catch(Exception $e){
			$rows = Null;
		}
		return $rows;
	}
	
	/**
	* Returns all course associations for the specified volunteer request
	* Term and Termmodifier behave as defined in Application_Model_Term
	*/
	public function selectCAs_VR($VRID){
		$associationModel = new Application_Model_DbTable_CourseAssociations();
		$query = 'RID = ' . $VRID;
		try{
				$rows = $associationModel->fetchAll($query)->toArray();
			}
		catch(Exception $e){
			$rows = Null;
		}
		return $rows;
	}

}
?>
